﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sovacode.RubiksCube.Common.Command;

namespace Sovacode.RubiksCube.Common.Tests.CommandManager
{
    [TestClass]
    public class CommonCommandsTests
    {
        [TestMethod]
        public void CreateCommand()
        {
            var commandOne = new RelayCommand<bool>(o => { }, p => true);

            Assert.IsNotNull(commandOne);
            Assert.IsTrue(commandOne.Type == CommandType.Normal);

            var commandTwo = new RelayCommand<bool>(o => { });

            Assert.IsNotNull(commandTwo);
            Assert.IsTrue(commandTwo.Type == CommandType.Normal);
        }


        [TestMethod]
        public void CanExecute()
        {
            var commCanExecOne = new RelayCommand<bool>(o => { }, p => true);
            var commCanExecTwo = new RelayCommand<bool>(o => { });
            var commCantExec = new RelayCommand<bool>(o => { }, p => false);

            Assert.IsTrue(commCanExecOne.CanExecute(null));
            Assert.IsTrue(commCanExecTwo.CanExecute(null));
            Assert.IsFalse(commCantExec.CanExecute(null));
        }

        [TestMethod]
        public void Execute()
        {
            var command = new RelayCommand<bool>(o => { }, p => true);

            command.Execute(true);
        }

        [TestMethod]
        public void ExecuteWithParameter()
        {
            var commCanExecOne = new RelayCommand<string>(o => { }, p => true);
            var commCanExecTwo = new RelayCommand<string>(o => { });

            var commCanExecThree = new RelayCommand<string>(o => { }, p => true);
            var commCanExecFour = new RelayCommand<string>(o => { });

            commCanExecOne.Execute("some");
            commCanExecTwo.Execute("some");

            commCanExecThree.Execute(null);
            commCanExecFour.Execute(null);
        }
    }
}
